import { createRouter, createWebHashHistory } from 'vue-router'
const routes = [
  {
    path: '/',
    component: () => import('@/views/Layout/Layout.vue'),
    children: [{
      path: '/',
      component: () => import('@/views/Home')
    },
    {
      path: '/category/:id',
      component: () => import('@/views/Category')
    },
    {
      path: '/category/sub/:id',
      component: () => import('@/views/Category/Sub')
    },
    {
      path: '/goods/:id',
      component: () => import('@/views/Goods')
    }]
  },
  {
    path: '/login',
    component: () => import('@/views/Login')
  },
  {
    path: '/play',
    component: () => import('@/views/Playground')
  },
  {
    path: '/login/callback',
    component: () => import('@/views/Login/callback')
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes,
  scrollBehavior (to, from, savedPosition) {
    // 始终滚动到顶部
    return { top: 0 }
  }
})

export default router
